package com.mz.ozy.mvp.presenter;


import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.OrderListBean;
import com.mz.ozy.mvp.model.MySellKtModel;
import com.mz.ozy.mvp.view.MySellKtContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class MySellPresenter extends BasePresenterImpl<MySellKtContract.View> implements MySellKtContract.Presenter {

    private MySellKtModel mModel;

    public MySellPresenter() {
        mModel = new MySellKtModel();
    }


    @Override
    public void geAssetsInfo(Activity activity, String type, String ordertype, String orderState, String page) {
        mModel.geAssetsInfo(activity, type, ordertype, orderState, page)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<OrderListBean>(mView) {
                    @Override
                    public void onSuccesss(OrderListBean bean) {
                        mView.geAssetsInfoSuccess(bean);
                    }
                });
    }

    @Override
    public void cancelOrder(Context context, int id) {
        mModel.cancelOrder(context, id)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<OrderListBean>(mView) {
                    @Override
                    public void onSuccesss(OrderListBean bean) {
                        mView.cancelOrderSuccess(bean);
                    }
                });
    }
}
